<?php
# 文件名称:core.php
# MetInfo在线反馈系统 
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
defined( '_SYS' ) or die( 'No direct script access allowed' );
$TM  		=_import('timemark');
$TM->mark('core_start');
//是否有缓存文件存在
$cache_name = md5($SYS->uri->uri_string());
if($SYS->config->item('caching')==1 && !defined( 'ISADMIN' ) )
{	
	$cache = _import('cache/cache');
	if($cache->get($cache_name))
	{
		echo $cache->get($cache_name);
		exit();
	}
}
//加载控制类
 
_import('mvc/controller', FALSE);
//判断
if ( ! file_exists(PATH_BASE.DS.'controllers'.DS.$SYS->router->fetch_directory().$SYS->router->fetch_class().EXT))
{
	show_error('Unable to load your default controller.  Please make sure the controller specified in your Routes.php file is valid.');
}
include(PATH_BASE.DS.'controllers'.DS.$SYS->router->fetch_directory().$SYS->router->fetch_class().EXT);

$class  = $SYS->router->fetch_class();
$method = $SYS->router->fetch_method();
if ( ! class_exists($class)
	OR $method == 'controller'
	OR strncmp($method, '_', 1) == 0
	)
{
	show_404("{$class}/{$method}");
}
//开始执行
$mainframe = new $class();

// 调用请求的方法
// 并传递"/"分割的值0->class,1->function,2->id
call_user_func_array(array(&$mainframe, 'execute'), array($method));
//call_user_func_array(array(&$mainframe, $method), array_slice($SYS->uri->rsegments, 2));
//var_dump($URI->rsegments);
//$OUT->cache(2);
//将渲染后的数据发送到浏览器
echo $SYS->response->toString();
if($SYS->config->item('caching')==1 && !defined( 'ISADMIN' ))
{	
	$cache->cache_time = $SYS->config->item('cachetime');
	$cache->set($cache_name,$SYS->response->toString());
}
$TM->mark('core_end');
//echo '页面执行花费时间:'.$TM->elapsed_time('core_start','core_end');
# 本程序是一个开源系统,使用时请你仔细阅读使用协议,商业用途请自觉购买商业授权.
# Copyright (C) 长沙米拓信息技术有限公司 (http://www.metinfo.cn). All rights reserved.
?>